
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JComponent;
import java.util.Iterator;

public class DotComponent extends JComponent implements MouseListener
{
	public static final int finger_size=30;
	public static final int object_size=60;
	public static final int table_size=760;
	private DotGenerator dots;
	private int width=1920;
	private int height=1080;
	private float scale=1.0f;
	private static final int NUMBER_OF_DOTS=2000;
	private int score=0;
	
	public DotComponent()
	{
		dots = new DotGenerator(width, height);
		for(int i=0;i<NUMBER_OF_DOTS;i++)
		{
			dots.generateDot();
		}
	}
	
	public void setSize(int w, int h)
	{
		width=w;
		height=h;
	}
	
	public void paint(Graphics g)
	{
		update(g);
	}
	
	public void update(Graphics g)
	{		
		dots = new DotGenerator(width, height);
		score+=10;
		for(int i=0;i<NUMBER_OF_DOTS;i++)
		{
			dots.generateDot();
		}
		Graphics2D g2 = (Graphics2D)g; //g2d takes in g
		g2.setColor(Color.BLACK);	//Color set to black
		g2.fillRect(0, 0, width, height); //draws rectangle at 0,0
		g2.setPaint(Color.WHITE);
		//g2.drawString("Score: "+score, 50, 50);
		Iterator<Dot> iter = dots.gDots().iterator();
		while(iter.hasNext())
		{
			Dot curr = iter.next();
			g2.setColor(curr.gColor());
			g2.fillOval(curr.gX(), curr.gY(), curr.gSize(), curr.gSize());
		}
		repaint();
	}
	
	@Override
	public void mouseClicked(MouseEvent arg0)
	{
		// TODO Auto-generated method stub

		repaint();
	}
	@Override
	public void mouseEntered(MouseEvent arg0)
	{
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseExited(MouseEvent arg0) 
	{
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mousePressed(MouseEvent arg0)
	{
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseReleased(MouseEvent arg0)
	{
		// TODO Auto-generated method stub
		
	}
}
